var Urls = 'http://appuser.orz3.top';
//切割url
var url_current =window.location.href;
var ur_current2 = url_current.split("?");
var ur_current3 = ur_current2[1];
var Ids = ur_current3.split("&")[0];
var takens = ur_current3.split("&")[1];
var Id = Ids.split('=')[1];
var takenId = takens.split('=')[1];
//var Id = 3;
//var takenId = 4444;

//var url_current = window.location.href;
//var ary = url_current.split("?"); //用“&”将URL分割成2部分每部分都有你需要的东西;
//var url1 = ary[1]; //获取到URL的另一部分"id=1";
//var Id = url1.split("=")[1]; //获取到id的值 1
//提交报名
$('.footer_app').on('click', function() {
	getval();
})

function getval() {
	var user_name = $('.user_name').val();
	var sax = $("input[name='period']:checked").val()
	var mobilephone = $('.mobilephone').val();
	var email = $('.email').val();
	var regName = /^[ \u4e00-\u9fa5A-Za-z]+$/;
	var regTel = /^1[3-8]\d{9}$/;
	if(!regName.test(user_name)) {
		layer.msg('输入名字不合法', {
			icon: 2,
			time: 1500
		});
		return false;
	}
	if(sax == "") {
		layer.msg('请填写性别', {
			icon: 2,
			time: 1500
		});
		return false;
	}
	if(!regTel.test(mobilephone)) {
		layer.msg('请输入正确手机号', {
			icon: 2,
			time: 1500
		});
		return false;
	}
	if(email == "") {
		layer.msg('请填写邮箱', {
			icon: 2,
			time: 1500
		});
		return false;
	}
	$.ajax({
		type: "post",
		url: Urls + "/api/Activity/ActivityEmroll",
		data: JSON.stringify({
			"ActivityId": Id,
			"MemberAccount": takenId,
			"Name": user_name,
			"Sex": sax,
			"Phone": mobilephone,
			"Email": email
		}),
		success: function(res) {
			console.log(res);
			if(res.ErrorCode == -1) {
				alert("提交失败！")
				return false;
			}
			if(res.ErrorCode == 0) {
				$('.fuzzy').css('display', 'block');
			}
		}
	})

}

//渲染数据
$.ajax({
	type: "post",
	url: Urls + "/api/Activity/GetActivityDetail",
	data: JSON.stringify({
		"ActivityId": Id,
		"MemberAccount": ""
	}),
	success: function(res) {
		var data = res.Data.ActivityList;
		$('.hangder_img').find('img').attr('src', data.PhotoUrl)
		$('.starttime').text(data.StartTime);
		$('.endtime ').text(data.EndTime);
		$('.content h4').text(data.ActivityTitle);
		$('.title').text(data.ActivityTitle);
		document.querySelector('.content_p').innerHTML = data.ActivityDescription;
	}
});